/*
 * @Author: xiaosihan 
 * @Date: 2024-01-28 07:20:02 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-01-28 10:07:26
 */


import utils from "@utils";
import { Group, MeshStandardMaterial } from "three";
import Text3D from "three-base/Text3D";

export default class FloorNum extends Group {

    constructor() {
        super();
    }

    material = new MeshStandardMaterial({
        color: "#00fbff",
        metalness: 0,
        roughness: 0.3
    });

    floorNum = 0;
    floorHeight = 0.3;
    // 设置楼层数
    setFloorNum(floorNum: number) {
        this.floorNum = floorNum;

        this.children.map(o => o.visible = false);

        for (let i = 0; i < floorNum; i++) {
            if (this.children[i]) {
                this.children[i].visible = true;
            } else {
                const num = new Text3D(String(i + 1));
                num.setText({
                    size: 0.2,
                    height: 0.001, // 文字的厚度
                    bevelEnabled: false, // 斜角开启
                    bevelThickness: 0.02, // 斜角厚度
                    bevelSize: 0.015, // 斜角大小
                    bevelOffset: 0,// 斜角偏移
                    bevelSegments: 3,//斜角分段
                });
                num.material = this.material;

                //three事件
                num.userData = {
                    cursor: "pointer",
                    enableEvent: true,
                };

                // num.addEventListener("dbclick", e => {
                //     utils.materialEditor("text3d", this.material);
                // });

                num.position.set(0, (i + 3) * this.floorHeight, 0);
                this.add(num);
            }
        }


    }


}